#!/usr/bin/python
#coding:utf-8

import requests
import re
from random import choice

class Bomber():
    def __init__(self, username='', password='', ua=''):
        self.session = None
        self.username = username
        self.password = password
        self.ua = ua
        self.sid = ''
        self.proxy = ''
        self.forums = ['20', '18', '23', '12', '16', '21', '19', '9', '3', '22', '4']
        self.subject = 'Ничего личного'
        self.text = 'Привет, как дела?'
        
    
    def login(self):
        session = requests.session()
        self.session = session
        proxies_list = {}
        if self.proxy:
            proxies_list = {'http':self.proxy}
        req = session.post('http://forum.online-solutions.ru/login.php', data={'login':'Log in', 'password':self.password, 'redirect':'', 'username':self.username}, headers={'User-Agent':self.ua}, proxies=proxies_list)
        print req.content
        req = session.get('http://forum.online-solutions.ru/profile.php?mode=editprofile')
        print ' '*50
        print req
        print req.content
        self.sid = req.cookies['phpbb2mysql_sid']
        print self.sid
        pass

    def set_proxy(self, proxy):
        self.proxy = proxy
    
    def create_post(self):
        #http://forum.online-solutions.ru/posting.php?mode=newtopic&f=20
        content = {}
        content['add_poll_option_text'] =''
        content['f'] = '20'
        content['message'] = 'mega large text'
        content['mode'] = 'newtopic'
        content['poll_length'] = ''
        content['poll_title'] = ''
        content['post'] = 'Submit'
        content['sid'] = self.sid
        content['subject'] = 'subbbbbbject'

        session = self.session
        req = session.post('http://forum.online-solutions.ru/posting.php?mode=newtopic&f=20', data=content)
        pass
    
    def create_answer(self):
        pass